<?php
/**
 * Akimimi front
 * QueryReplyDao
 * @author by M.Wang
 */

require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class QueryReplyDao extends BaseDao {

	/**
	 * Table name
	 *
	 * @var string
	 */
	private $tableName = 'query_replies';
	
	/**
	 * Get mix info by query_id
	 *
	 * @param int $int_queryid
	 * @return array
	 */
	public function getReplyInfoByQueryId( $int_queryid ){
		$str_sql = "
		  SELECT *
		  FROM `{$this->tableName}` AS `r`
		  WHERE `r`.`query_id` = ? AND `r`.`is_delete` = 0
		  ORDER BY `r`.`created` DESC LIMIT 0,1
		";
		return $this->dbUtil->SelectData($str_sql, array( $int_queryid ) );
	}
	
	public function getReplyInfoById( $int_id ){
		$str_sql = "
		  SELECT *
		  FROM `{$this->tableName}` AS `r`
		  WHERE `r`.`id` = ? AND `r`.`is_delete` = 0";
		return $this->dbUtil->SelectData($str_sql, array( $int_id ) );
	}
	
}

?>
